package com.xjj.service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjj.entity.Menu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author : 王泰元
 * @date : 2022/10/20 10:34
 */
@Repository
public interface MenuMapper extends BaseMapper<Menu> {

    @Select("select m.id , name , link , pid , icon , status " +
            "from xjj_menu m, xjj_role_menu rm " +
            "where rm.menu_id = m.id " +
            "and rm.role_id = #{roleId} " +
            "and m.pid = 0")
    List<Menu> getPMenusByRoleId(Integer roleId);

    @Select("select m.id , name , link , pid , icon , status " +
            "from xjj_menu m, xjj_role_menu rm " +
            "where rm.menu_id = m.id " +
            "and rm.role_id = #{roleId} " +
            "and m.pid = #{pid}")
    List<Menu> getSubMenusByRoleId(@Param("roleId") Integer roleId, @Param("pid") Integer pid);
}
